package com.yuan.springcloud.controller;

import com.yuan.springcloud.entities.Dept;
import com.yuan.springcloud.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: jinshengyuan
 * Date: 2019-03-22
 * Time: 14:52
 * description:
 **/
@RestController
public class DeptController {

    @Autowired
    private DeptService deptService;

    @PostMapping(value = "dept/add")
    @ResponseBody
    public boolean add(Dept dept){
        return deptService.add(dept);
    }

    @GetMapping(value = "dept/get/{id}")
    @ResponseBody
    public Dept get(@PathVariable(value = "id") Long id){
        System.out.println("id:"+id);
        System.out.println(deptService.getDeptById(id));
        return deptService.getDeptById(id);
    }

    @GetMapping(value = "dept/list")
    @ResponseBody
    public List<Dept> list(){
        return deptService.getAll();
    }
}
